package com.soxing.braindata.scheduler;

import com.soxing.braindata.service.stat.IStatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;

/**
 * @author :durango
 * @date :2022/8/21 11:29
 * @description 课题统计调度器
 */
@Slf4j
@Configuration
public class ResearchStatScheduler {


    @Resource
    private IStatService sexRateStatService;

    @Resource
    private IStatService collectionBarServiceImpl;

    @Resource
    private IStatService complianceRateService;

    @Resource
    private IStatService finishBarServiceImpl;

    @Resource
    private IStatService qABarServiceImpl;

    @Resource
    private IStatService qualityRateServiceImpl;

    @Resource
    private IStatService testeeFinishImpl;

    @Resource
    private IStatService yearBarServiceImpl;

    /**
     * 性别统计
     */
//    @Scheduled(cron = "0/5 * * * * ?")
    @Scheduled(cron = "0 0 0 * * ?")
    private void sexRateStat() {
        log.info("=========课题性别统计开始=========");
        sexRateStatService.stat(null, null, null);
        log.info("=========课题性别统计结束=========");
    }

    /**
     * 被试配合程度统计 高/中/低
     */
//    @Scheduled(cron = "0/5 * * * * ?")
    @Scheduled(cron = "0 0 0 * * ?")
    private void testeeAdaptabilityStat() {
        log.info("=========被试配合程度统计开始=========");
        complianceRateService.stat(null,null,null);
        log.info("=========被试配合程度统计结束=========");
    }

    /**
     * 主观质量评估统计 高/中/低
     */
//    @Scheduled(cron = "0/5 * * * * ?")
    @Scheduled(cron = "0 0 0 * * ?")
    private void subjectiveQualityStat() {
        log.info("=========主观质量评估统计开始=========");
        qualityRateServiceImpl.stat(null,null,null);
        log.info("=========主观质量评估统计结束=========");
    }

    /**
     * 被试配合程度统计 高/中/低
     */
//    @Scheduled(cron = "0/5 * * * * ?")
     @Scheduled(cron = "0 0 0 * * ?")
    private void testeeAdaptability() {
        log.info("=========被试配合程度统计开始=========");
        complianceRateService.stat(null,null,null);
        log.info("=========被试配合程度统计结束=========");
    }

    /**
     * 中心完成情况统计
     */
//    @Scheduled(cron = "0/5 * * * * ?")
    @Scheduled(cron = "0 0 0 * * ?")
    private void centerPerformanceStat() {
        log.info("=========中心完成情况统计开始=========");
        finishBarServiceImpl.stat(null,null,null);
        log.info("=========中心完成情况统计结束=========");
    }

    /**
     * 年龄分布情况统计
     */
//    @Scheduled(cron = "0/5 * * * * ?")
    @Scheduled(cron = "0 0 0 * * ?")
    private void ageDistributeStat() {
        log.info("=========年龄分布情况统计开始=========");
        yearBarServiceImpl.stat(null,null,null);
        log.info("=========年龄分布情况统计结束=========");
    }

    /**
     * QA分布情况统计
     */
//    @Scheduled(cron = "0/5 * * * * ?")
     @Scheduled(cron = "0 0 0 * * ?")
    private void qaDistributeStat() {
        log.info("=========QA分布情况统计开始=========");
        qABarServiceImpl.stat(null,null,null);
        log.info("=========QA分布情况统计结束=========");
    }

    /**
     * 近12个月采集概况统计
     */
//    @Scheduled(cron = "0/5 * * * * ?")
    @Scheduled(cron = "0 0 0 * * ?")
    private void recentCollectStat() {
        log.info("=========近12个月采集概况统计开始=========");
        collectionBarServiceImpl.stat(null,null,null);
        log.info("=========近12个月采集概况统计结束=========");
    }

//    @Scheduled(fixedRate = 3000)
//    public void fixedRateJob() {
//
//        System.out.println("fixedRate 每隔3秒" +"启动的任务");
//    }
//    @Scheduled(cron = "0/5 * * * * ?")
    @Scheduled(cron = "0 0 0 * * ?")
    private void testeeFinishStat() {
        log.info("=========受试者完成度统计开始=========");
        testeeFinishImpl.stat(null,null,null);
        log.info("=========受试者完成度统计结束=========");
    }



}
